package com.aerozhonghuan.logisticsmall.modules.order;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aerozhonghuan.logisticsmall.R;
import com.aerozhonghuan.logisticsmall.framework.base.TitlebarFragment;
import com.aerozhonghuan.logisticsmall.modules.common.MainActivity;

/**
 * Created by ChenLin on 2019/5/28 14:33.Email&WeChat:7877409@163.com
 * 申请结果页面
 */
public class SubmitResultFragment extends TitlebarFragment {

    private View rootView;
    private String mCode;
    private String mMoney;
    private String billId;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.layout_submit_result, null);
            if (getArguments() == null || !getArguments().containsKey("money") || !getArguments().containsKey("billId")) {
                alert("数据异常");
                getActivity().finish();
            }
            mCode = getArguments().getString("code");
            mMoney = getArguments().getString("money");
            billId = getArguments().getString("billId");
            initView();
            initData();
        }
        return rootView;
    }

    private void initView() {
        TextView tvOrderCode = (TextView) rootView.findViewById(R.id.tv_order_code);
        TextView tvOrderMoney = (TextView) rootView.findViewById(R.id.tv_order_money);
        tvOrderCode.setText(mCode);
        tvOrderMoney.setText(mMoney);
        rootView.findViewById(R.id.btn_to_main).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SubmitResultFragment.this.getContext().startActivity(new Intent(SubmitResultFragment.this.getContext(), MainActivity.class).putExtra("tab", "0"));
            }
        });
        rootView.findViewById(R.id.btn_to_order).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), OrderDetailAcrivity.class).putExtra("billId", billId));
                getActivity().finish();
            }
        });
    }

    private void initData() {
    }
}
